# coding: utf-8

import utils.ztjy_db_connection_pool as pool
from config import setting

conn = pool.get_connection(
    user='szy',
    password='yP0tfUTHvP5q',
    host='172.16.200.17',
    port=3306
)

cur = conn.cursor()
sql = 'select content_id, content_seg from {} where is_delete = 0 and is_online = 1'.format('dbword2vec.t_article')
cur.execute(sql)
all_data = cur.fetchall()
print(len(all_data))
with open(setting.MODEL_DIR + '/article_seg_with_content_id', 'w+', encoding='utf-8') as f:
    for item in all_data:
        f.write('{},{}'.format(item[0].decode(), item[1].decode()) + '\n')
